<?php
//naincludujeme potrebne classy, zapneme nette
require '../nette/Nette/loader.php';
Debug::enable();
require '../db.php';
require '../localization/lang.php';
require '../core/core.sanitizer.php';
require '../core/core.security.php';
session_start();
$loc=new loc;
//ak prislo logging info, skontrolujem a ked je to ok tak sa lognem


if (isset($_POST['log_in'])) {
$login = new core_security;
$login->username=$_POST['username'];
$login->passwd=$_POST['passwd'];
$login_validation_message=$login->checkuser_validate();
$login->setlogin();
}
if (isset($_POST['logout'])) {
if ($_POST['logout'] == "log out") {
$login = new core_security;
$login->unsetlogin();
}
}

if (isset($_SESSION['logged'])) {


if ($_SESSION['logged'] == "OK") {
	if ($_SESSION['role'] >= 3) {require 'main.inc_nopriv.php';}
	if ($_SESSION['role'] < 3) {
		if (isset($_POST['page'])) {
			if ($_POST['page'] == "statistics" AND $_SESSION['role'] < 2) { 
				require 'statistics.inc.php';
				} else {
				require 'main.inc.php';
				}
		} else {
		require 'main.inc.php';
		}
	}


	//tu sa naincluduje user stranka

	//require 'main.inc.php';
	
}
}else{ 
require '../login_form.inc.php';
}
?>
